<meta charset="UTF-8">
<?php
require 'h.php';
$db->query('set names utf8');
$id=isset($_GET['bid'])?$_GET['bid']:0;

if(empty($_POST)){

$sqlsel="select * from t_message where id='$id'";
$selrs=$db->query($sqlsel);
$row=$selrs->fetch_assoc();
require 'edit_html.php';
}
 else {
$username=$_POST['username'];
$message=$_POST['message'];
$imgurl=$_POST['imgurl'];
$sex=$_POST['sex'];
$sqlupdate="update t_message set username='$username',message='$message',imgurl='$imgurl',sex='$sex' where id='$id'";
$aaa=$db->query($sqlupdate);

if($aaa){
     echo "<script language='javascript' type='text/javascript'>";
    echo "alert('留言成功！');";
    echo "window.location.href='index.php';";
    echo "</script>";
}
 else {
    echo '留言不成功';    
}
 }